package com.axt.manager.bean;

import com.axt.soa.bean.*;
import com.axt.soa.msg.types.MsgParam;
import com.axt.dbaudit.model.query.Session;
import com.axt.manager.base.*;
import com.axt.manager.model.*;

import java.util.*;

public class AuthBean extends BaseFuncBean {
	/**
	 * 添加权限
	 * 
	 * @return
	 */
	public int addAuth(String roleId, String serverId, String userId) {
		prepare();
		request.addParam(MsgParam.PARA_ROLE_ID, roleId);
		request.addParam(MsgParam.PARA_SVR_ID, serverId);
		request.addParam(MsgParam.PARA_TG_USER_ID, userId);

		return execute(MsgFuncExt.FUNC_ADD_AUTH, CONN_T_TCP);
	}

	/**
	 * 
	 * @return
	 */
	public List<Auth> queryAuthList() {
		prepare();
		
		return fetch(MsgFuncExt.FUNC_GET_AUTH, 
				"com.axt.manager.model.Auth", MsgParam.PARA_AUTH_LIST, CONN_T_TCP);
	}

	/**
	 * 删除权限
	 */
	public int deleteAuth(String authId) {
		prepare();
		request.addParam(MsgParam.PARA_AUTH_ID, authId);
		
		return execute(MsgFuncExt.FUNC_DELETE_AUTH, CONN_T_TCP);
	}

	/**
	 * 删除权限
	 */
	public int deleteAuth(String userId, String serverId) {
		prepare();
		request.addParam(MsgParam.PARA_TG_USER_ID, userId);
		request.addParam(MsgParam.PARA_SVR_ID, serverId);
		
		return execute(MsgFuncExt.FUNC_DELETE_AUTH, CONN_T_TCP);
	}
}
